
<script language="javascript">
  $(document).ready(function(){
    $("#searchDate").click(function () {
      var fechaInicio = $('#from').val();
      var fechaFin = $('#to').val();
      $("#orders_list").load('<? echo $this->Html->url('../Orders/search') ?>',{fechaInicio:fechaInicio, fechaFin:fechaFin });

    });
  })
</script> 


<?php
echo $this->Html->script('date');
?>

<div class="orders index indexOnly">
  <section class="search dateForm">

    <h2><?php echo __('Ordenes de Ruta Emitidas'); ?></h2>

    <table class="searchOrders">
      <?php echo $this->Form->create('Order', array('action' => 'index')); ?>
      <tr>
        <td> <?php echo $this->Form->input('client_company_id', array('label' => false, 'empty' => 'Seleccione Empresa', 'div' => false)); ?> </td>
      </tr>
      <tr>
        <td> <?php echo $this->Form->input('company_id', array('label' => false, 'empty' => 'Seleccione Transporte')); ?> </td>
      </tr>
    </table>
    <br>
    <label for="from">Fecha Desde</label>
    <input type="text" id="from" name="from" value="<?php echo isset($from) ? $from : '' ?>"/>
    <label for="to">Hasta</label>
    <input type="text" id="to" name="to" value="<?php echo isset($to) ? $to : '' ?>" />

    <?php echo $this->Form->end(array('label' => '', 'class' => 'buttonLupa2', 'div' => false, 'id' => 'searchDate')) ?>
    <?php // echo $this->Html->Link('Exportar a Excel', array('action' => 'export', isset($client_company) ? $client_company : '', isset($company) ? $company : '', isset($from) ? $from : '', isset($to) ? $to : ''), array('id' => 'export')); ?>


        <?php 
               if (empty($from)){
                $from = '*';
                }
               if (empty($to)){
                $to = '*';
                }
               if (empty($client_company)){
                $client_company = '*';
                }
               if (empty($company)){
                $company = '*';
                }
?>


        <a class="export_excel" href="/orders/export/<?php echo $from ?>/<?php echo $to ?>/<?php echo $company ?>/<?php echo $client_company ?> "> Exportar a Excel</a>
  </section>
  <br>
  <div id="orders_list">
    <?php echo $this->element('orders/table') ?>

  </div>
</div>
<!--<div class="actions">
  <h3><?php // echo __('Actions');       ?></h3>
  <ul>
    <li><?php // echo $this->Html->link(__('New Order'), array('action' => 'add'));       ?></li>
    <li><?php // echo $this->Html->link(__('Home'), array('controller' => 'companies', 'action' => 'index'));       ?> </li>
    <li><?php // echo $this->Html->link(__('Listado de Choferes'), array('controller' => 'drivers', 'action' => 'index'));       ?> </li>
    <li><?php // echo $this->Html->link(__('Listado de Camiones'), array('controller' => 'vehicles', 'action' => 'index'));       ?> </li>
    <li><?php // echo $this->Html->link(__('Listado de Acoplados'), array('controller' => 'coupleds', 'action' => 'index'));       ?> </li>
    <li><?php // echo $this->Html->link(__('Listado de Productos'), array('controller' => 'products', 'action' => 'index'));       ?> </li>
  </ul>
</div>-->